package com.adinnet.admin.peaseRecord.controller;


import com.adinnet.admin.classs.model.vo.ClassResp;
import com.adinnet.admin.classs.model.vo.ClasssReq;
import com.adinnet.admin.classs.service.ClasssService;
import com.adinnet.admin.common.service.CommonService;
import com.adinnet.admin.course.service.CourseService;
import com.adinnet.admin.organization.service.OrganizationService;
import com.adinnet.admin.peaseRecord.model.vo.PeaseRecordReq;
import com.adinnet.admin.peaseRecord.model.vo.PeaseRecordResp;
import com.adinnet.admin.peaseRecord.service.PeaseRecordService;
import com.adinnet.admin.school.service.SchoolService;
import com.adinnet.admin.system.model.vo.SysUserInfo;
import com.adinnet.core.BaseController;
import com.adinnet.core.PageResult;
import com.baomidou.mybatisplus.extension.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * <p>
 * 豌豆记录表 前端控制器
 * </p>
 *
 * @author zYshuai
 * @since 2020-12-15
 */
@Controller
@RequestMapping("admin/peaseRecord")
public class PeaseRecordController extends BaseController {


    @Autowired
    private OrganizationService organizationService;

    @Autowired
    private SchoolService schoolService;

    @Autowired
    private CommonService commonService;

    @Autowired
    private ClasssService classsService;

    @Autowired
    private PeaseRecordService peaseRecordService;

    @RequestMapping()
    public String peaseRecord(Model model) {
        SysUserInfo sysUserInfo=commonService.getLoginUser();
        model.addAttribute("organizationList", organizationService.getListByUserRole(sysUserInfo));//机构列表
        model.addAttribute("schoolList",schoolService.getListByUserRole(sysUserInfo));//校区列表
        model.addAttribute("classList",classsService.getListByUserRole(sysUserInfo));//班级列表
        return "peaseRecord/peaseRecord.html";
    }

    /**
     * 根据权限查询金豆明细
     **/
    @ResponseBody
    @RequestMapping("/list")
    public PageResult<PeaseRecordResp> list(PeaseRecordReq peaseRecordReq) {
        SysUserInfo sysUserInfo = commonService.getLoginUser();
        return peaseRecordService.peaseRecordList(peaseRecordReq, sysUserInfo);
    }

}
